class Solution {
public:
    bool row[10][10];
    bool cow[10][10];
    bool ret[3][3][10];
    bool isValidSudoku(vector<vector<char>>& board) {
        for (int i = 0; i < 9; ++i) {
            for (int j = 0; j < 9; ++j) {
                if (board[i][j] != '.') {
                    int num = board[i][j] - '0';
                    if (row[i][num] || cow[j][num] || ret[i / 3][j / 3][num])
                        return false;
                    row[i][num] = true;
                    cow[j][num] = true;
                    ret[i / 3][j / 3][num] = true;
                }
            }
        }
        return true;
    }
};
